]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Fix lint errors prior to refactor
authorEvan Welsh <contact@evanwelsh.com>
Fri, 7 Jul 2023 20:12:49 +0000 (13:12 -0700)
committerEvan Welsh <contact@evanwelsh.com>
Sat, 8 Jul 2023 01:32:50 +0000 (18:32 -0700)
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>

js/ui/dateMenu.js

index e7bdb6dbb9bcd7a8b52481eb66e299cb07b015b4..a1298e5469ab57ddfab8378c81e28f621c6ba0eb 100644 (file)
@@ -18,7 +18,7 @@ const Calendar = imports.ui.calendar;
 const Weather = imports.misc.weather;
 const System = imports.system;
 
-const { loadInterfaceXML } = imports.misc.fileUtils;
+const {loadInterfaceXML} = imports.misc.fileUtils;
 
 const NC_ = (context, str) => `${context}\u0004${str}`;
 const T_ = Shell.util_translate_time_string;
@@ -29,13 +29,25 @@ const EN_CHAR = '\u2013';
 const ClocksIntegrationIface = loadInterfaceXML('org.gnome.Shell.ClocksIntegration');
 const ClocksProxy = Gio.DBusProxy.makeProxyWrapper(ClocksIntegrationIface);
 
+/**
+ * @private
+ *
+ * @param {Date} date a Date
+ * @returns {boolean}
+ */
 function _isToday(date) {
     let now = new Date();
-    return now.getYear() == date.getYear() &&
-           now.getMonth() == date.getMonth() &&
-           now.getDate() == date.getDate();
+    return now.getFullYear() === date.getFullYear() &&
+           now.getMonth() === date.getMonth() &&
+           now.getDate() === date.getDate();
 }
 
+/**
+ * @private
+ *
+ * @param {GLib.DateTime} datetime a GLib.DateTime
+ * @returns {Date}
+ */
 function _gDateTimeToDate(datetime) {
     return new Date(datetime.to_unix() * 1000 + datetime.get_microsecond() / 1000);
 }
@@ -53,7 +65,7 @@ class TodayButton extends St.Button {
             reactive: false,
         });
 
-        let hbox = new St.BoxLayout({ vertical: true });
+        const hbox = new St.BoxLayout({vertical: true});
         this.add_actor(hbox);
 
         this._dayLabel = new St.Label({
@@ -62,7 +74,7 @@ class TodayButton extends St.Button {
         });
         hbox.add_actor(this._dayLabel);
 
-        this._dateLabel = new St.Label({ style_class: 'date-label' });
+        this._dateLabel = new St.Label({style_class: 'date-label'});
         hbox.add_actor(this._dateLabel);
 
         this._calendar = calendar;
@@ -85,15 +97,15 @@ class TodayButton extends St.Button {
          * "Tue 9:29 AM").  The string itself should become a full date, e.g.,
          * "February 17 2015".
          */
-        let dateFormat = Shell.util_translate_time_string(N_("%B %-d %Y"));
+        const dateFormat = Shell.util_translate_time_string(N_('%B %-d %Y'));
         this._dateLabel.set_text(date.toLocaleFormat(dateFormat));
 
         /* Translators: This is the accessible name of the date button shown
          * below the time in the shell; it should combine the weekday and the
          * date, e.g. "Tuesday February 17 2015".
          */
-        dateFormat = Shell.util_translate_time_string(N_("%A %B %e %Y"));
-        this.accessible_name = date.toLocaleFormat(dateFormat);
+        const dateAccessibleNameFormat = Shell.util_translate_time_string(N_('%A %B %e %Y'));
+        this.accessible_name = date.toLocaleFormat(dateAccessibleNameFormat);
     }
 });
 
@@ -192,8 +204,8 @@ class EventsSection extends St.Button {
         const startsBeforeToday = eventStart < this._startDate;
         const endsAfterToday = eventEnd > this._endDate;
 
-        const startTimeOnly = Util.formatTime(eventStart, { timeOnly: true });
-        const endTimeOnly = Util.formatTime(eventEnd, { timeOnly: true });
+        const startTimeOnly = Util.formatTime(eventStart, {timeOnly: true});
+        const endTimeOnly = Util.formatTime(eventEnd, {timeOnly: true});
 
         const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
 
@@ -330,7 +342,7 @@ class WorldClocksSection extends St.Button {
 
         this._locations = [];
 
-        let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
+        const layout = new Clutter.GridLayout({orientation: Clutter.Orientation.VERTICAL});
         this._grid = new St.Widget({
             style_class: 'world-clocks-grid',
             x_expand: true,
@@ -383,7 +395,7 @@ class WorldClocksSection extends St.Button {
         for (let i = 0; i < clocks.length; i++) {
             let l = world.deserialize(clocks[i]);
             if (l && l.get_timezone() != null)
-                this._locations.push({ location: l });
+                this._locations.push({location: l});
         }
 
         const unixtime = GLib.DateTime.new_now_local().to_unix();
@@ -396,9 +408,9 @@ class WorldClocksSection extends St.Button {
         });
 
         let layout = this._grid.layout_manager;
-        let title = this._locations.length == 0
-            ? _("Add world clocks…")
-            : _("World Clocks");
+        const title = this._locations.length === 0
+            ? _('Add world clocks…')
+            : _('World Clocks');
         const header = new St.Label({
             style_class: 'world-clocks-header',
             x_align: Clutter.ActorAlign.START,
@@ -422,7 +434,7 @@ class WorldClocksSection extends St.Button {
                 x_expand: true,
             });
 
-            let time = new St.Label({ style_class: 'world-clocks-time' });
+            const time = new St.Label({style_class: 'world-clocks-time'});
 
             const tz = new St.Label({
                 style_class: 'world-clocks-timezone',
@@ -433,7 +445,7 @@ class WorldClocksSection extends St.Button {
             time.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
             tz.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
 
-            if (this._grid.text_direction == Clutter.TextDirection.RTL) {
+            if (this._grid.text_direction === Clutter.TextDirection.RTL) {
                 layout.attach(tz, 0, i + 1, 1, 1);
                 layout.attach(time, 1, i + 1, 1, 1);
                 layout.attach(label, 2, i + 1, 1, 1);
@@ -491,7 +503,7 @@ class WorldClocksSection extends St.Button {
         for (let i = 0; i < this._locations.length; i++) {
             let l = this._locations[i];
             const now = GLib.DateTime.new_now(l.location.get_timezone());
-            l.timeLabel.text = Util.formatTime(now, { timeOnly: true });
+            l.timeLabel.text = Util.formatTime(now, {timeOnly: true});
         }
     }
 
@@ -541,7 +553,7 @@ class WeatherSection extends St.Button {
 
         this.child = box;
 
-        let titleBox = new St.BoxLayout({ style_class: 'weather-header-box' });
+        let titleBox = new St.BoxLayout({style_class: 'weather-header-box'});
         this._titleLabel = new St.Label({
             style_class: 'weather-header',
             x_align: Clutter.ActorAlign.START,
@@ -558,7 +570,7 @@ class WeatherSection extends St.Button {
         });
         titleBox.add_child(this._titleLocation);
 
-        let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
+        let layout = new Clutter.GridLayout({orientation: Clutter.Orientation.VERTICAL});
         this._forecastGrid = new St.Widget({
             style_class: 'weather-grid',
             layout_manager: layout,
@@ -600,7 +612,7 @@ class WeatherSection extends St.Button {
             if (datetime.difference(current) < GLib.TIME_SPAN_HOUR)
                 continue; // Enforce a minimum interval of 1h
 
-            if (infos.push(forecasts[i]) == MAX_FORECASTS)
+            if (infos.push(forecasts[i]) === MAX_FORECASTS)
                 break; // Use a maximum of five forecasts
 
             current = datetime;
@@ -612,7 +624,7 @@ class WeatherSection extends St.Button {
         let layout = this._forecastGrid.layout_manager;
 
         let infos = this._getInfos();
-        if (this._forecastGrid.text_direction == Clutter.TextDirection.RTL)
+        if (this._forecastGrid.text_direction === Clutter.TextDirection.RTL)
             infos.reverse();
 
         let col = 0;
@@ -654,7 +666,7 @@ class WeatherSection extends St.Button {
 
     _setStatusLabel(text) {
         let layout = this._forecastGrid.layout_manager;
-        let label = new St.Label({ text });
+        let label = new St.Label({text});
         layout.attach(label, 0, 0, 1, 1);
     }
 
@@ -678,11 +690,11 @@ class WeatherSection extends St.Button {
         if (!this._weatherClient.hasLocation)
             return;
 
-        const { info } = this._weatherClient;
+        const {info} = this._weatherClient;
         this._titleLocation.text = this._findBestLocationName(info.location);
 
         if (this._weatherClient.loading) {
-            this._setStatusLabel(_("Loading…"));
+            this._setStatusLabel(_('Loading…'));
             return;
         }
 
@@ -692,9 +704,9 @@ class WeatherSection extends St.Button {
         }
 
         if (info.network_error())
-            this._setStatusLabel(_("Go online for weather information"));
+            this._setStatusLabel(_('Go online for weather information'));
         else
-            this._setStatusLabel(_("Weather information is currently unavailable"));
+            this._setStatusLabel(_('Weather information is currently unavailable'));
     }
 
     _sync() {
@@ -787,7 +799,7 @@ class FreezableBinLayout extends Clutter.BinLayout {
     }
 
     set frozen(v) {
-        if (this._frozen == v)
+        if (this._frozen === v)
             return;
 
         this._frozen = v;
@@ -819,7 +831,7 @@ class FreezableBinLayout extends Clutter.BinLayout {
 var CalendarColumnLayout = GObject.registerClass(
 class CalendarColumnLayout extends Clutter.BoxLayout {
     _init(actors) {
-        super._init({ orientation: Clutter.Orientation.VERTICAL });
+        super._init({orientation: Clutter.Orientation.VERTICAL});
         this._colActors = actors;
     }
 
@@ -842,7 +854,7 @@ class DateMenuButton extends PanelMenu.Button {
 
         super._init(0.5);
 
-        this._clockDisplay = new St.Label({ style_class: 'clock' });
+        this._clockDisplay = new St.Label({style_class: 'clock'});
         this._clockDisplay.clutter_text.y_align = Clutter.ActorAlign.CENTER;
         this._clockDisplay.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
 
@@ -857,7 +869,7 @@ class DateMenuButton extends PanelMenu.Button {
             coordinate: Clutter.BindCoordinate.SIZE,
         }));
 
-        let box = new St.BoxLayout({ style_class: 'clock-display-box' });
+        let box = new St.BoxLayout({style_class: 'clock-display-box'});
         box.add_actor(indicatorPad);
         box.add_actor(this._clockDisplay);
         box.add_actor(this._indicator);
@@ -867,12 +879,12 @@ class DateMenuButton extends PanelMenu.Button {
         this.add_style_class_name('clock-display');
 
         let layout = new FreezableBinLayout();
-        let bin = new St.Widget({ layout_manager: layout });
+        let bin = new St.Widget({layout_manager: layout});
         // For some minimal compatibility with PopupMenuItem
         bin._delegate = this;
         this.menu.box.add_child(bin);
 
-        hbox = new St.BoxLayout({ name: 'calendarArea' });
+        hbox = new St.BoxLayout({name: 'calendarArea'});
         bin.add_actor(hbox);
 
         this._calendar = new Calendar.Calendar();